class Solution(object):
    def maxA(self, n):
        """
        :type n: int
        :rtype: int
        """
        if n <= 6:
            return n
        else:
            DP = [0] * n
            for i in range(6):
                DP[i] = i + 1
            for i in range(6, n):
                DP[i] = max(2 * DP[i - 3], 3 * DP[i - 4], 4 * DP[i - 5], 5 * DP[i - 6])
            return DP[-1]



data = Solution()
n = 20
print(data.maxA(n))
